Skip to content

Conversation

estebank
Copy link
Contributor

@estebank estebank commented Aug 6, 2019

  • Change expected/found for type mismatches in break
  • Be more accurate when talking about diverging match arms
  • Tweak wording of function without a return value
  • Suggest calling bare functions when their return value can be coerced to the expected type
  • Give more parsing errors when encountering foo(_, _, _)

Fix #51767, fix #62677, fix #63136, cc #37384, cc #35241, cc #51669.

@rust-highfive
Copy link
Contributor

r? @matthewjasper

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 6, 2019
@rust-highfive

This comment has been minimized.

@estebank estebank changed the title Tweak mismatched types error on break expressions Tweak mismatched types error Aug 7, 2019
@estebank
Copy link
Contributor Author

estebank commented Aug 8, 2019

cc @Centril @varkor

Copy link
Contributor

@Centril Centril left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit shorter + return is an expr. :)

@estebank
Copy link
Contributor Author

estebank commented Aug 8, 2019

r? @Centril

Copy link
Contributor

@Centril Centril left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r=me when-green with or without the change below depending on whether you feel that is an improvement :)

@varkor
Copy link
Contributor

varkor commented Aug 8, 2019

Looks great!

@estebank
Copy link
Contributor Author

estebank commented Aug 9, 2019

@bors r=Centril

@bors
Copy link
Collaborator

bors commented Aug 9, 2019

📌 Commit 68aff3f has been approved by Centril

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 9, 2019
Centril added a commit to Centril/rust that referenced this pull request Aug 9, 2019
Tweak mismatched types error

- Change expected/found for type mismatches in `break`
- Be more accurate when talking about diverging match arms
- Tweak wording of function without a return value
- Suggest calling bare functions when their return value can be coerced to the expected type
- Give more parsing errors when encountering `foo(_, _, _)`

Fix rust-lang#51767, fix rust-lang#62677, fix rust-lang#63136, cc rust-lang#37384, cc rust-lang#35241.
bors added a commit that referenced this pull request Aug 9, 2019
Rollup of 4 pull requests

Successful merges:

 - #61937 (Improve `ptr_rotate` performance, tests, and benches)
 - #63302 (Update LLVM submodule)
 - #63337 (Tweak mismatched types error)
 - #63397 (Add tests for some ICEs)

Failed merges:

r? @ghost
@Centril
Copy link
Contributor

Centril commented Aug 9, 2019

Failed in #63401 (comment), @bors r-
Rebasing + --bless should be enough.

@estebank
Copy link
Contributor Author

estebank commented Aug 9, 2019

@bors r=Centril rebased

@bors
Copy link
Collaborator

bors commented Aug 9, 2019

📌 Commit 45a5bc7 has been approved by Centril

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 9, 2019
Centril added a commit to Centril/rust that referenced this pull request Aug 9, 2019
Tweak mismatched types error

- Change expected/found for type mismatches in `break`
- Be more accurate when talking about diverging match arms
- Tweak wording of function without a return value
- Suggest calling bare functions when their return value can be coerced to the expected type
- Give more parsing errors when encountering `foo(_, _, _)`

Fix rust-lang#51767, fix rust-lang#62677, fix rust-lang#63136, cc rust-lang#37384, cc rust-lang#35241.
Centril added a commit to Centril/rust that referenced this pull request Aug 9, 2019
Tweak mismatched types error

- Change expected/found for type mismatches in `break`
- Be more accurate when talking about diverging match arms
- Tweak wording of function without a return value
- Suggest calling bare functions when their return value can be coerced to the expected type
- Give more parsing errors when encountering `foo(_, _, _)`

Fix rust-lang#51767, fix rust-lang#62677, fix rust-lang#63136, cc rust-lang#37384, cc rust-lang#35241, cc rust-lang#51669.
Centril added a commit to Centril/rust that referenced this pull request Aug 10, 2019
Tweak mismatched types error

- Change expected/found for type mismatches in `break`
- Be more accurate when talking about diverging match arms
- Tweak wording of function without a return value
- Suggest calling bare functions when their return value can be coerced to the expected type
- Give more parsing errors when encountering `foo(_, _, _)`

Fix rust-lang#51767, fix rust-lang#62677, fix rust-lang#63136, cc rust-lang#37384, cc rust-lang#35241, cc rust-lang#51669.
Centril added a commit to Centril/rust that referenced this pull request Aug 10, 2019
Tweak mismatched types error

- Change expected/found for type mismatches in `break`
- Be more accurate when talking about diverging match arms
- Tweak wording of function without a return value
- Suggest calling bare functions when their return value can be coerced to the expected type
- Give more parsing errors when encountering `foo(_, _, _)`

Fix rust-lang#51767, fix rust-lang#62677, fix rust-lang#63136, cc rust-lang#37384, cc rust-lang#35241, cc rust-lang#51669.
bors added a commit that referenced this pull request Aug 10, 2019
Rollup of 7 pull requests

Successful merges:

 - #63056 (Give built-in macros stable addresses in the standard library)
 - #63337 (Tweak mismatched types error)
 - #63350 (Use associated_type_bounds where applicable - closes #61738)
 - #63394 (Add test for issue 36804)
 - #63399 (More explicit diagnostic when using a `vec![]` in a pattern)
 - #63419 (check against more collisions for TypeId of fn pointer)
 - #63423 (Mention that tuple structs are private if any of their fields are)

Failed merges:

r? @ghost
@bors
Copy link
Collaborator

bors commented Aug 10, 2019

⌛ Testing commit 45a5bc7 with merge d19a359...

@bors bors merged commit 45a5bc7 into rust-lang:master Aug 10, 2019
Centril added a commit to Centril/rust that referenced this pull request Aug 25, 2019
…trochenkov

Suggest calling closure with resolved return type when appropriate

Follow up to rust-lang#63337. CC rust-lang#63100.

```
error[E0308]: mismatched types
  --> $DIR/fn-or-tuple-struct-without-args.rs:46:20
   |
LL |     let closure = || 42;
   |                   -- closure defined here
LL |     let _: usize = closure;
   |                    ^^^^^^^
   |                    |
   |                    expected usize, found closure
   |                    help: use parentheses to call this closure: `closure()`
   |
   = note: expected type `usize`
              found type `[closure@$DIR/fn-or-tuple-struct-without-args.rs:45:19: 45:24]`
```
bors added a commit that referenced this pull request Sep 1, 2019
Suggest call fn ctor passed as arg to fn with type param bounds

_Reviewer note: the relevant changes are in the second commit, the first is simple and mechanical, but verbose._

When forgetting to call a fn in an argument position to an fn that has a generic bound:

```rust
async fn foo() {}

fn bar(f: impl Future<Output=()>) {}

fn main() {
    bar(foo); // <- should be `bar(foo());`
}
```

suggest calling it:

```
error[E0277]: the trait bound `fn() -> impl std::future::Future {foo}: std::future::Future` is not satisfied
  --> $DIR/async-fn-ctor-passed-as-arg-where-it-should-have-been-called.rs:9:5
   |
LL | fn bar(f: impl Future<Output=()>) {}
   | --------------------------------- required by `bar`
...
LL |     bar(foo);
   |     ^^^ the trait `std::future::Future` is not implemented for `fn() -> impl std::future::Future {foo}`
   |
   = help: it looks like you forgot to use parentheses to call the function: `foo()`
```

Fix #63100. Follow up to #63833 and #63337.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
6 participants